﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace QLThuVien
{
    class TacGia
    {
        string tentg, matg;
        public TacGia() { }
        public TacGia(string matacgia, string tacgia)
        {
            this.matg = matacgia;
            this.tentg = tacgia;
        }

        public void set_matacgia(string matacgia)
        {
            this.matg = matacgia;
        }

        public void set_tentacgia(string tentacgia)
        {
            this.tentg = tentacgia;
        }

        public bool taomoi()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("insert into tacgia values('" + matg + "',N'" + tentg + "')") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }

        public bool update()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("update tacgia set tentg=N'" + tentg + "' where matg='" + matg + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }

        public bool xoa()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("delete from tacgia where matg='" + matg + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }
    }
}
